﻿CREATE PROCEDURE [dbo].[TempArticles_InsertDataFromTempSales]
	
AS
	INSERT INTO TempArticles(RangeReviewId, CategoryId, Code, Name, EAN, UOM, Brand, Manufacturer, NotFoundCategory, Size, Width, Height, Facings, Attribute1, Attribute2, Attribute3, Attribute4, Attribute5, TaxRate)
	SELECT distinct RangeReviewId, CategoryId, ArticleCode, MAX(ArticleName) ArticleName, MAX(EAN) EAN, UOM, MAX(Brand) Brand, MAX(Manufacturer) Manufacturer, MAX(NotFoundCategory), MAX(Size), MAX(Width), MAX(Height), MAX(Facings), MAX(Attribute1), MAX(Attribute2), MAX(Attribute3), MAX(Attribute4), MAX(Attribute5), MAX(TaxRate)
	FROM TempArticleSales
	group by RangeReviewId, CategoryId, ArticleCode, UOM
RETURN 0